package org.xxpay.pay.channel.simplepay;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.Assert;
import org.xxpay.common.unify.AbstractPaymentConfig;

public class SimplepayPayConfig extends AbstractPaymentConfig {
    public static final String CHANNEL_NAME = "simplepay";
    public static final String CHANNEL_NAME_SIMPLEPAY_ALIPAY_QR = CHANNEL_NAME + "_aliqr";
    public static final String CHANNEL_NAME_SIMPLEPAY_WX_QR = CHANNEL_NAME + "_wxqr";

    public static final String RESPONSE_RESULT_FAIL = "fail";
    public static final String RESPONSE_RESULT_OK = "OK"; // 返回上游成功

    ///public static final String QUERY_REQ_DOMAIN = "http://api.trustpayinalipay.fun:8080";//域名和端口
    public static final String REQ_PAY_URL_FIXX = "/tp/api/v1/customer/order";//支付路径
    public static final String QUERY_REQ_TRANSFER_URL = "/tp/api/v1/customer/cash/withdrawing";//代付路径
    public static final String QUERY_REQ_TRANSFER_QUERY_URL = "/tp/api/v1/customer/cash/";//代付查询路径
    SimplepayPayConfig(String payParam){
        Assert.notNull(payParam, "init sft config error");
        JSONObject object = JSON.parseObject(payParam);
        setAppId(object.getString("appId"));
        setPrivateKey(object.getString("privatekey"));
        setRequestUrl(object.getString("requestUrl"));
        setPayMode(object.getString("payMode"));
        setPartnerId(object.getString("channelId"));
    }

//    public static String getReqUrl(String type){
//        String reqUrl = QUERY_REQ_DOMAIN;
//        switch (type){
//            case "pay":
//               reqUrl += QUERY_REQ_PAY_URL;
//               break;
//            case "pay_query":
//               reqUrl +="";
//               break;
//            case "transfer":
//                reqUrl+=QUERY_REQ_TRANSFER_URL;
//                break;
//            case "transfer_query":
//                reqUrl += QUERY_REQ_TRANSFER_QUERY_URL;
//                break;
//                default: break;
//        }
//        return reqUrl;
//    }
}
